"""
YouTour - Create and access tours based on public transport routes. 
Copyright (C) 2011 Karl Beecher

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""

import datetime
from data.Models import TourDB, StopDB
from data.DbInterface import DbInterface

class Tour():

    tourId = ""

    languageId = ""

    title = ""

    description = ""

    # List of descriptions of the tour (each a different language version of same tour)
    tourDescriptionList = {}

    countryId = ""

    cityId = ""

    startPosition = ""

    endPosition = ""

    startTime = datetime.time(10, 0)

    endTime = datetime.time(10, 0)

    # List of tickets needed    
    ticketList = {}

    # List of stops on the tour
    stopList = []

    def __init__(self):
        self.tourId = ""
        self.languageId = ""
        self.title = ""
        self.description = ""
        self.DescriptionList = {}
        self.countryId = ""
        self.cityId = ""
        self.startPosition = ""
        self.endPosition = ""
        self.startTime = datetime.time(10, 0)
        self.endTime = datetime.time(10, 0)
        self.ticketList = {}
        self.stopList = []

    def dbStore(self):
        """
        Instruct this tour to store itself in the datastore.
        """
        tourDB = TourDB()
        tourDB.title = self.title
        tourDB.description = self.description
        tourDB.startPosition = self.startPosition
        tourDB.endPosition = self.endPosition
        tourDB.startTime = self.startTime
        tourDB.endTime = self.endTime

        DbInterface.storeTour(tourDB)

        for s in self.stopList:
            stopDB = StopDB()
            stopDB.tourId = tourDB
            stopDB.description = s.description
            stopDB.stopNumber = s.stopNumber
            stopDB.directions = s.directions

            DbInterface.storeStop(stopDB)
